Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#357 Debouncer for setting the initials #363

Closed
wants to merge 8 commits into from

Conversation

3rdvision
Copy link
Contributor

- -
Issue #357
Decisions - Use debouncer timer initialsDebounce=275 for setInitials and setInitialsExtra.
- Adapt tests

Notes:

  • Frontend and backend debouncer strategies were tested and had similar response times.
  • Doing a debouncer within update was the first approach but failed to be optimal as the event initials_extra triggers for an update with a null params.reason and it's not possible to adapt it without a huge refactor.

@3rdvision 3rdvision added the enhancement New feature or request label Feb 28, 2022
@3rdvision 3rdvision self-assigned this Feb 28, 2022
@ripe-tobias-bot
Copy link

Woof, Woof!

Thank you @3rdvision for submitting the "#357 Debouncer for setting the initials" pull request 😎.

Please do not forget to review our internal guidelines:

  • Review the code in the PR using a peer 🧑‍🤝‍🧑
  • Make sure all the linting process has been executed an passed 👌
  • Make sure unit tests are passing ✅
  • Ensure that proper code standards are met 📋
  • Fill in the PR's summary (issue, dependencies, decisions and GIF)
  • Double-check the diff to make sure it's the absolute best solution you can come up with

Engaging in the development process in the best possible way helps it being efficient and fast.

Your friend,
Tobias (Platforme's mascot)

Tobias Bot

@ripe-tobias-bot
Copy link

Woof, Woof!

Oops! @3rdvision you may have to fix some errors:

  • Please try to solve the conflicts and then re-assign PR. ❗️

Please address these issues to continue with the Pull Request merge process.

Your friend,
Tobias (Platforme's mascot)

Tobias Bot

Copy link
Contributor

@BeeMargarida BeeMargarida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3rdvision Just to check, did you explore a possible solution where a cancel flag is used to stop the update promise before the existence of loadedCallback?
For example, setting a cancelFlag on cancel that would be unset after the cancel request in update. If the flag was true during the update process (for example before getImageUrl or doubleBuffer) it would return immediately and not complete the whole update

README.md Outdated Show resolved Hide resolved
@3rdvision
Copy link
Contributor Author

Just to check, did you explore a possible solution where a cancel flag is used to stop the update promise before the existence of loadedCallback?

I did made an implementation of it but it didn't offer much performance difference. The problem is update will await any previous updates here after it cancels pending updates here and there wasn't a significant performance improvement, maybe about from 6.2s to 5.2s while using the debouncer it's about 6.2s to 3.1s.

It's also difficult to distinguish set initials update. In some places we have reason specifying set initials but because we also trigger initials_extra to notify the client that the initials changed after setInitialsExtra, we have a bind for initials_extra and in other places which will do a setInitials later without including params.reason="set initials_extra" and even thought we could refactor to always track it, from what I've tried, that experience didn't hold significant performance improvements versus this one.

Co-authored-by: Ana Margarida Silva <[email protected]>
@BeeMargarida
Copy link
Contributor

BeeMargarida commented Mar 1, 2022

Just to check, did you explore a possible solution where a cancel flag is used to stop the update promise before the existence of loadedCallback?

I did made an implementation of it but it didn't offer much performance difference. The problem is update will await any previous updates here after it cancels pending updates here and there wasn't a significant performance improvement, maybe about from 6.2s to 5.2s while using the debouncer it's about 6.2s to 3.1s.

It's also difficult to distinguish set initials update. In some places we have reason specifying set initials but because we also trigger initials_extra to notify the client that the initials changed after setInitialsExtra, we have a bind for initials_extra and in other places which will do a setInitials later without including params.reason="set initials_extra" and even thought we could refactor to always track it, from what I've tried, that experience didn't hold significant performance improvements versus this one.

What I was sugesting was end the updatePromise earlier on cancel, since if the update process did yet not reach the new Promise..... that is saved as loadedCallback when the cancel is called, the whole update is made. With the approach I mentioned, this does not happen. For example, when writting a whole word, only the last request is completed (with the whole word), instead of the first and then the last.

Example inside _update closure in update:

...
// verifies if the model currently loaded in the Ripe Instance can
// render the frame to be display and if that's not the case "ignores"
// the current request for update
if (frame && !this.owner.hasFrame(frame)) {
    this.trigger("not_loaded");
    return false;
}

if (this.cancelFlag) return;

// builds the URL of the image using the frame hacking approach
// this should provide us with the new values
const url = this.owner._getImageURL({
    frame: frame,
    ...
});
...

The cancelFlag is set as true in the cancel method and as false after the cancel call in update. If the previous update has not yet reached the assignment of this._loadedCallback, the _update method would return instead of executing until the end.

@3rdvision
Copy link
Contributor Author

Closing this in favor of a more performant approach #366

joamag added a commit that referenced this pull request Mar 12, 2022
#363 YSL: Improve update cancellation strategy
joao-conde added a commit that referenced this pull request Jun 8, 2022
@joao-conde joao-conde deleted the dva/set_initials_debouncer branch November 23, 2022 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants